﻿using System.Windows;
using Caliburn.Micro;
using Ninject;
using Spotted.Core;
using Spotted.Data.Args;
using Spotted.Data.Repositories;

namespace Spotted.ViewModels
{
    public class LoginPageViewModel : ViewModelBase
    {
        [Inject]
        public IAppService ApplicationService { get; set; }

        [Inject]
        public IUserRepository UserRepository { get; set; }

        private readonly INavigationService _navigationService;

        public string EmailAddress { get; set; }
        public string Password { get; set; }

        // properties
        private bool _canLogin = true;
        public bool CanLogin
        {
            get { return _canLogin; }
            private set
            {
                _canLogin = value;
                NotifyOfPropertyChange("CanLogin");
            }
        }

        public LoginPageViewModel(INavigationService navigationService) : base(navigationService)
        {
            _navigationService = navigationService;
        }

        // behaviors
        public void Login()
        {
            CanLogin = false;
            ApplicationService.ShowProgressIndicator("Authenticating - Please Wait");
        }

        public void Register()
        {
            _navigationService.UriFor<RegisterPageViewModel>().Navigate();
        }

        public void FacebookLogin()
        {
            _navigationService.UriFor<FacebookRegisterPageViewModel>().Navigate();
        }
    }
}
